﻿using Abp.Dependency;
using Mt.Site.Core.WorkFlows.Process;
using Mt.Site.Core.WorkFlows.Process.Models;
using System.Threading.Tasks;

namespace Mt.Site.Core.WorkFlows.Diy.Plugin.Impl.tougao
{
    public class TougaoShenheNode : WorkFlowNodePluginFunctionsBase, ITransientDependency
    {
        public const string Name = "WFNode.tougao.shenhe";

        public override string DisplayName => "新闻投稿（审核）";

        public override string UniqeName => Name;

        /// <inheritdoc/>
        public override async Task AfterSaveFormAsync(UpdateFormDataInput input, IWorkFlowManager workFlowManager)
        {
            var paper = workFlowManager.CurrentPaper.Paper;
            if (input.Values.ContainsKey(WorkFlowConst.FieldName.Content2.Title))
            {
                paper.ChangeTitle(input.Values[WorkFlowConst.FieldName.Content2.Title]);
            }

            if (input.Values.ContainsKey(WorkFlowConst.FieldName.Content2.PublishTime))
            {
                paper.ChangeRegistrationTime(input.Values[WorkFlowConst.FieldName.Content2.PublishTime]);
            }
            else
            {
                paper.ChangeRegistrationTime(null);
            }

            await Task.FromResult(0);
        }
    }
}
